import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.h2.jdbcx.JdbcConnectionPool;

public class H2 {

	/**
	 * @param args
	 * @throws SQLException 
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws SQLException, ClassNotFoundException {
		
		Class.forName("org.h2.Driver");

		JdbcConnectionPool cp = JdbcConnectionPool.
		    create("jdbc:h2:~/test", "sa", "");
		Connection conn = cp.getConnection();
		
		PreparedStatement prepareStatement = conn.prepareStatement("select * from test");
		ResultSet executeQuery = prepareStatement.executeQuery();
		executeQuery.first();
		executeQuery.next();
		String string = executeQuery.getString(2);
		System.out.println(string);
		
		conn.close(); cp.dispose();
		
	}

}
